﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<script type="text/javascript" src="../jquery/jquery.js"></script>
	</head>
	<body>
		<table border="1" align="center">
			<thead>
				<tr>
					<th>状态</th>
					<th>用户名</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td><input type="checkbox" /></td>
					<td>赵</td>
				</tr>
				<tr>
					<td><input type="checkbox" /></td>
					<td>钱</td>
				</tr>
				<tr>
					<td><input type="checkbox" /></td>
					<td>孙</td>
				</tr>
				<tr>
					<td><input type="checkbox" /></td>
					<td>李</td>
				</tr>
				<tr>
					<td><input type="checkbox" /></td>
					<td>周</td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td>
						<input type="checkbox" />
						全选
					</td>
					<td>
						<input type="button" value="全反选" />
					</td>
				</tr>
			</tfoot>
		</table>
		
		<script type="text/javascript">
			//全选中和全取消
			$("table tfoot :checkbox").click(function(){
				/* 
				只能实现一次，第二次全选的时候不好使了，不知道为啥
				var checkBoxCh = $("table tbody input").attr("checked");
				alert(checkBoxCh);
				if(checkBoxCh == undefined){
					$("table tbody input").attr("checked","checked");
				}else{
					$("table tbody input").removeAttr("checked");
				} */
				
				var flag = this.checked;
				if(flag){
					$("table tbody :checkbox").attr("checked","checked");
				}else{
					$("table tbody :checkbox").removeAttr("checked");
				}
			});
		</script>
		
		<script type="text/javascript">
			//全反选
		</script>
		
	</body>
</html>



